   // API基础URL - 使用云函数触发器URL
   export const API_URL = 'https://cloud1-0gs6bsbjb24a0b82.service.tcloudbase.com/yyb-photo-api';
   
   // 获取通用请求头
   export const getHeaders = () => {
     const headers = {
       'Content-Type': 'application/json'
     };
     
     // 如果有JWT令牌，添加到请求头
     const token = localStorage.getItem('token');
     if (token) {
       headers['Authorization'] = `Bearer ${token}`;
     }
     
     return headers;
   };

   // 通用API调用函数
   export const callAPI = async (endpoint, method = 'GET', data = null) => {
     try {
       const options = {
         method,
         headers: getHeaders(),
         credentials: 'include' // 包含跨域cookie
       };
       
       if (data && (method === 'POST' || method === 'PUT')) {
         options.body = JSON.stringify(data);
       }
       
       const response = await fetch(`${API_URL}/${endpoint}`, options);
       
       // 处理401未授权错误
       if (response.status === 401) {
         localStorage.removeItem('token');
         window.location.href = '/login';
         return null;
       }
       
       const result = await response.json();
       return result;
     } catch (error) {
       console.error('API调用错误:', error);
       throw error;
     }
   };